package com.csthink.auditlog.mq.payload;

/**
 * @author <a href="mailto:security.2009@live.cn">Mars</a>
 * @since 2023-09-12
 */
public class ESPayload {

    public static final String UPSERT_EVENT = "upsert";
    public static final String DELETE_EVENT = "delete";

    private String event;
    private Long timestamp;
    private Object data;

    public static ESPayload of(String event, Object data, long timestamp) {
        ESPayload payload = new ESPayload();
        payload.setEvent(event);
        payload.setTimestamp(timestamp);
        payload.setData(data);
        return payload;
    }

    public static ESPayload of(Object data) {
        ESPayload payload = new ESPayload();
        payload.setEvent(UPSERT_EVENT);
        payload.setTimestamp(System.currentTimeMillis());
        payload.setData(data);
        return payload;
    }


    public String getEvent() {
        return event;
    }

    public void setEvent(String event) {
        this.event = event;
    }

    public Long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
